<h3>Fiche de frais du mois <?php echo $numMois . "-" . $numAnnee ?> : </h3>
<div class="encadre">
    <p>
        Etat : <?php echo $libEtat ?> depuis le <?php echo $dateModif ?> <br> Montant validé : <?php echo $montantValide ?>    
    </p>
    <form method='post' action='index.php?uc=validerFrais&action=afficherFiche'>
        <table class="listeLegere">
            <caption>Eléments forfaitisés </caption>
            <tr>
                <?php
                foreach ($lesFraisForfait as $unFraisForfait) {
                    $libelle = $unFraisForfait['libelle'];
                    ?>	
                    <th><?php echo $libelle ?></th>
                    <?php
                }
                ?>
            </tr>
            <tr>
                <?php
                foreach ($lesFraisForfait as $unFraisForfait) {
                    $quantite = $unFraisForfait['quantite'];
                    $idFrais = $unFraisForfait['idfrais'];
                    ?>
                    <td class="qteForfait"><input type='text' size="12" name='fraisforfait[<?php echo $idFrais; ?>]' value='<?php echo $quantite ?>'> </td>
                    <?php
                }
                ?>
            </tr>
        </table>
        <p class='right'>
            <input type='hidden' name='idV' value='<?php echo $idVisiteur; ?>'>
            <input type='hidden' name='mois' value='<?php echo $leMois; ?>'>
            <input type ='submit' value='Valider'>
            <input type ='reset' value='Réinitialiser'>
        </p>
    </form>
    <table class="listeLegere">
        <caption>Descriptif des éléments hors forfait -<input type='text'value='<?php echo $nbJustificatifs ?>' /> justificatifs reçus -
        </caption>
        <tr>
            <th class="date">Date</th>
            <th class="libelle">Libellé</th>
            <th class='montant'>Montant</th>
            <th class='action' colspan='2'>Action</th>
        </tr>
        <?php
        foreach ($lesFraisHorsForfait as $unFraisHorsForfait) {

            $idFraisHF = $unFraisHorsForfait['id'];
            $date = $unFraisHorsForfait['date'];
            $libelle = $unFraisHorsForfait['libelle'];
            $montant = $unFraisHorsForfait['montant'];
            $already = strstr($unFraisHorsForfait['libelle'], 'REFUSER -');

            if ($already == FALSE) {
                ?>
                <tr>
                <?php } else { ?>
                <tr class="red">
                <?php } ?>
                <td><?php echo $date ?></td>
                <td><?php echo $libelle ?></td>
                <td><?php echo $montant ?></td>
                <td><a href="index.php?uc=validerFrais&action=supprimerFraisHF&idfraisHF=<?php echo $idFraisHF; ?>&v=<?php echo $idVisiteur; ?>&m=<?php echo $leMois; ?>" >Supprimer</a></td>
                <td><a href="index.php?uc=validerFrais&action=reporterFraisHF&idfraisHF=<?php echo $idFraisHF; ?>&v=<?php echo $idVisiteur; ?>&m=<?php echo $leMois; ?>" >Reporter </a></td>     
            </tr>
            <?php
        }
        ?>
    </table>
    <form action="index.php?uc=validerFrais&action=validerFiche" method="post">
        <div>
            <p class="right">

                <?php
                $montantFraisHF = 0;
                $montantFraisF = 0;
                foreach ($lesFraisHorsForfait as $unFraisHorsForfait) {
                    $already = strstr($unFraisHorsForfait['libelle'], 'REFUSER -');

                    if ($already == FALSE) {
                        $montantFraisHF = $montantFraisHF + $unFraisHorsForfait['montant'];
                    }
                }
                foreach ($lesFraisForfait as $unFraisForfait) {
                    
                    $idFF=$unFraisForfait['idfrais'];
                    $quantite=$unFraisForfait['quantite'];
                    
                    
                    foreach ($typemontant as $id => $montantduF) {
                        
                        if ($idFF == $id) {
                            $montantFraisF = $montantFraisF + ($quantite * $montantduF);
                         
                        }
                       
                    }
                 
                }
                $montantaValider = $montantFraisF + $montantFraisHF;
                ?>
                <input type="hidden" value="<?php echo $montantaValider; ?>" name="MAV" />
                <input type="hidden" value="<?php echo $idVisiteur; ?>" name="idV" />
                <input type="hidden" value="<?php echo $leMois; ?>" name="leMois" />
                <input id="ok" type="submit" value="Valider la fiche" size="20" />

            </p> 
        </div>
    </form>
</div>